library(DiagrammeR)
library(tidyverse)

knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE)

Introduction

Current process used to update dashboards in MI team

A more efficient method

Step 1: Excel -> MongoDB

The data needs to be pasted into a macro enabled Excel file. The macro sends active sheet to a MongoDB database with name matching the sheet name before first underscore and collection matching the full sheet name.

To run the macro, while on the sheet you want to send, just use CTRL+W key combination.

Step 1: MongoDB setup

MongoDB provides a way of creating endpoints in the cloud (known as Mongo Realm). Since I first set this up, the method I used has been deprecated but it still works for now. The new process is not that different anyway.

An endpoint is associated with a JavaScript function. The function is used to tell Mongo how to handle the data, e.g. which database and collection to add it to. Since it is JavaScript, it provides an extremely versatile way of processing the data prior to saving it in the database!

An app set up in Realm can be downloaded and saved in source control along with the dashboard it is linked to.

Step 2: MongoDB -> Shiny

Once the data is in MongoDB, the next step is to be able to access this from Shiny. For this there are at least 3 packages. I chose to use the package mongolite as it seems the most recently active and well maintained.

A current issue is that on the VPN access to MongoDB is blocked. This means that when run locally, the app will always fall back to using the most recent data. Luckily, there are no problems with access when the app is deployed to shiny.io!

Step 2: Shiny code

In the Shiny app, there are 2 helper functions: get_mongo_collection and load_data. The first will get all records from a specified database and collection (and also save them to disk, i.e. the Shiny server). The second one attempts to use the first to get the data. If there is any error, it will instead fall back on using the most recently saved data. This prevents a complete catastrophe if the database has an outage for example.

Potential problems and improvements

Potential problems and improvements

Summary

We have went from this...

Summary

...to this

Questions?



MarkMc1089/FIC documentation built on April 3, 2022, 6:05 p.m.